<script setup>
import {useRouter} from "vue-router";
import TheWelcome from "@/components/TheWelcome.vue";

defineProps({
  msg: {
    type: String,
    required: true,
  },
})
const router = useRouter();

/*定义函数两种方式，方式一*/
// const navigateToMyVue = () => {
//   console.log('navigateToMyVue')
//   router.push({ name: 'MyVue' });
// };

/*定义函数两种方式，方式二*/
const navigateToMyVue = function () {
  console.log('navigateToMyVue2')
  // router.push({ name: 'MyVue' });
  router.push({name: 'myVue'});
};

</script>

<template>
  <div class="greetings">
    <h1 class="green">{{ msg }}</h1>
    <h3>
      You’ve successfully created a project with
      <a href="https://vite.dev/" target="_blank" rel="noopener">Vite</a> +
      <a href="https://vuejs.org/" target="_blank" rel="noopener">Vue 3</a>.
    </h3>
  </div>

  <div class="mt-4">
    <button class="btn btn-primary" @click="navigateToMyVue">跳转到我的Vue 页面</button>
  </div>

  <main>
    <TheWelcome/>
  </main>

</template>

<style scoped>
h1 {
  font-weight: 500;
  font-size: 2.6rem;
  position: relative;
  top: -10px;
}

h3 {
  font-size: 1.2rem;
}

.greetings h1,
.greetings h3 {
  text-align: center;
}

@media (min-width: 1024px) {
  .greetings h1,
  .greetings h3 {
    text-align: left;
  }
}
</style>
